﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsChiPhiBanHangChiTiet
    {
        private double mGiaBanNT = 0.0;
        private string mHanSuDung = "";
        private string mKhoa = "";
        private string mKhoaChiPhi = "";
        private string mKhoaDonViTinh = "";
        private string mKhoaHangHoa = "";
        private string mKhoaKho = "";
        private string mKhoaPhieuXuat = "";
        private string mLoaiTien = "";
        private string mNgayNhap = "";
        private double mQuyCach = 0.0;
        private string mSoLoHang = "";
        private double mSoLuong = 0.0;
        private string mSoSeri = "";
        private double mTienBanNT = 0.0;
        private double mTienPhi = 0.0;
        private double mTienPhiNT = 0.0;
        private double mTienThue = 0.0;
        private double mTyGia = 0.0;
        private int mTyLeThue = 0;

        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM BH_ChiPhiBanHangChiTiet WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mKhoaChiPhi = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mKhoaPhieuXuat = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mKhoaKho = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mKhoaHangHoa = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mSoLoHang = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                    this.mSoSeri = Conversions.ToString(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetString));
                    this.mNgayNhap = Conversions.ToString(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetString));
                    this.mHanSuDung = Conversions.ToString(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDonViTinh = Conversions.ToString(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetString));
                    this.mQuyCach = Conversions.ToDouble(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoLuong = Conversions.ToDouble(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetDecimal));
                    this.mGiaBanNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienBanNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetDecimal));
                    this.mTyLeThue = Conversions.ToInteger(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetInt32));
                    this.mTienThue = Conversions.ToDouble(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetDecimal));
                    this.mLoaiTien = Conversions.ToString(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetString));
                    this.mTyGia = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x11, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienPhiNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x12, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienPhi = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x13, modGeneral.typeOfColumn.GetDecimal));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[20];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaChiPhi", DbType.Int64, ParameterDirection.Input, this.mKhoaChiPhi);
                commandParameters[2] = DBHelper.createParameter("@KhoaPhieuXuat", DbType.Int64, ParameterDirection.Input, this.mKhoaPhieuXuat);
                commandParameters[3] = DBHelper.createParameter("@KhoaKho", DbType.Int64, ParameterDirection.Input, this.mKhoaKho);
                commandParameters[4] = DBHelper.createParameter("@KhoaHangHoa", DbType.Int64, ParameterDirection.Input, this.mKhoaHangHoa);
                commandParameters[5] = DBHelper.createParameter("@SoLoHang", DbType.Int64, ParameterDirection.Input, this.mSoLoHang);
                commandParameters[6] = DBHelper.createParameter("@SoSeri", DbType.Int64, ParameterDirection.Input, this.mSoSeri);
                commandParameters[7] = DBHelper.createParameter("@NgayNhap", DbType.Int64, ParameterDirection.Input, this.mNgayNhap);
                commandParameters[8] = DBHelper.createParameter("@HanSuDung", DbType.Int64, ParameterDirection.Input, this.mHanSuDung);
                commandParameters[9] = DBHelper.createParameter("@KhoaDonViTinh", DbType.Int64, ParameterDirection.Input, this.mKhoaDonViTinh);
                commandParameters[10] = DBHelper.createParameter("@QuyCach", DbType.Date, ParameterDirection.Input, this.mQuyCach);
                commandParameters[11] = DBHelper.createParameter("@SoLuong", DbType.Date, ParameterDirection.Input, this.mSoLuong);
                commandParameters[12] = DBHelper.createParameter("@GiaBanNT", DbType.Date, ParameterDirection.Input, this.mGiaBanNT);
                commandParameters[13] = DBHelper.createParameter("@TienBanNT", DbType.Date, ParameterDirection.Input, this.mTienBanNT);
                commandParameters[14] = DBHelper.createParameter("@TyLeThue", DbType.Double, ParameterDirection.Input, this.mTyLeThue);
                commandParameters[15] = DBHelper.createParameter("@TienThue", DbType.Date, ParameterDirection.Input, this.mTienThue);
                commandParameters[0x10] = DBHelper.createParameter("@LoaiTien", DbType.Int64, ParameterDirection.Input, this.mLoaiTien);
                commandParameters[0x11] = DBHelper.createParameter("@TyGia", DbType.Date, ParameterDirection.Input, this.mTyGia);
                commandParameters[0x12] = DBHelper.createParameter("@TienPhiNT", DbType.Date, ParameterDirection.Input, this.mTienPhiNT);
                commandParameters[0x13] = DBHelper.createParameter("@TienPhi", DbType.Date, ParameterDirection.Input, this.mTienPhi);
                if (DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "BH_ChiPhiBanHangChiTiet", commandParameters) > 0)
                {
                    return true;
                }
                flag = false;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public double GiaBanNT
        {
            get
            {
                return this.mGiaBanNT;
            }
            set
            {
                this.mGiaBanNT = value;
            }
        }

        public string HanSuDung
        {
            get
            {
                return this.mHanSuDung;
            }
            set
            {
                this.mHanSuDung = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaChiPhi
        {
            get
            {
                return this.mKhoaChiPhi;
            }
            set
            {
                this.mKhoaChiPhi = value;
            }
        }

        public string KhoaDonViTinh
        {
            get
            {
                return this.mKhoaDonViTinh;
            }
            set
            {
                this.mKhoaDonViTinh = value;
            }
        }

        public string KhoaHangHoa
        {
            get
            {
                return this.mKhoaHangHoa;
            }
            set
            {
                this.mKhoaHangHoa = value;
            }
        }

        public string KhoaKho
        {
            get
            {
                return this.mKhoaKho;
            }
            set
            {
                this.mKhoaKho = value;
            }
        }

        public string KhoaPhieuXuat
        {
            get
            {
                return this.mKhoaPhieuXuat;
            }
            set
            {
                this.mKhoaPhieuXuat = value;
            }
        }

        public string LoaiTien
        {
            get
            {
                return this.mLoaiTien;
            }
            set
            {
                this.mLoaiTien = value;
            }
        }

        public string NgayNhap
        {
            get
            {
                return this.mNgayNhap;
            }
            set
            {
                this.mNgayNhap = value;
            }
        }

        public double QuyCach
        {
            get
            {
                return this.mQuyCach;
            }
            set
            {
                this.mQuyCach = value;
            }
        }

        public string SoLoHang
        {
            get
            {
                return this.mSoLoHang;
            }
            set
            {
                this.mSoLoHang = value;
            }
        }

        public double SoLuong
        {
            get
            {
                return this.mSoLuong;
            }
            set
            {
                this.mSoLuong = value;
            }
        }

        public string SoSeri
        {
            get
            {
                return this.mSoSeri;
            }
            set
            {
                this.mSoSeri = value;
            }
        }

        public double TienBanNT
        {
            get
            {
                return this.mTienBanNT;
            }
            set
            {
                this.mTienBanNT = value;
            }
        }

        public double TienPhi
        {
            get
            {
                return this.mTienPhi;
            }
            set
            {
                this.mTienPhi = value;
            }
        }

        public double TienPhiNT
        {
            get
            {
                return this.mTienPhiNT;
            }
            set
            {
                this.mTienPhiNT = value;
            }
        }

        public double TienThue
        {
            get
            {
                return this.mTienThue;
            }
            set
            {
                this.mTienThue = value;
            }
        }

        public double TyGia
        {
            get
            {
                return this.mTyGia;
            }
            set
            {
                this.mTyGia = value;
            }
        }

        public int TyLeThue
        {
            get
            {
                return this.mTyLeThue;
            }
            set
            {
                this.mTyLeThue = value;
            }
        }
    }
}

